<template>
<div class="home">
	<HelloWorld></HelloWorld>
	<NavBar :items="items" :idx="idx" :showIconOrSrc="showIconOrSrc"  @change="change"></NavBar>
	<router-view/>
</div>
</template>

<script>
// @ is an alias to /src
// eslint-disable-next-line
/* eslint-disable */
import HelloWorld from '@/components/home/Home.vue'
import NavBar from '@/components/navbar/NavBar.vue'

export default {
  name: 'home',
  data() {
  	return {
  		idx: 0,
		showIconOrSrc: false,
		items: [{
			cls:"home",
			name:"首页",
			push:"/",
			icon: 'iconfont icon-shouye',
			iconSelect: 'iconfont icon-shouye',
			id: 0,
		},
		{
			cls:"guidang",
			name:"归档",
			push:"/guidang",
			icon: "iconfont icon-guidang",
			iconSelect: 'iconfont icon-guidang',
			id: 1
		},
		{
			cla:"about",
			name:"博主",
			push:"/about",
			icon: "iconfont icon-bozhuguanli",
			iconSelect: 'iconfont icon-bozhuguanli',
			id: 2
		},
		{
			cla:"lianjie",
			name:"链接",
			push:"/lianjie",
			icon: "iconfont icon-lianjie2",
			iconSelect: 'iconfont icon-lianjie2',
			id: 3
		}],
	}
  },
  components: {
    HelloWorld,
    NavBar
  },
  created() {
  	this.idx = this.beforeHand();
  },
  methods: {
	change(item) {
		this.idx = item.id
	},
	beforeHand() {
		let that = this;
		var id = 0;
		this.items.forEach( function(item, index) {
			if(item.push==that.$route.path){
				id = item.id;
				return ;
			}
		});
		return id;
	}
  },
}
</script>
